/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sisgea.controller;


import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.List;
import sisgea.bean.SoloBean;
import sisgea.bean.TipoExperimentoBean;
import sisgea.conexaobd.ConexaoPost;

/**
 *
 * @author Lau
 */
public class TipoExperimentoControl {
    
     PreparedStatement pstm;
    ResultSet rs;
    String consultatipoexperimento = "SELECT * FROM tblTipoExperimento WHERE TipoExperimento LIKE ?";
    String cadastratipoexperimento = "INSERT INTO tblSolo (Empresa, TipoExperimento, DescTipoExperimento, Observacao, UsuarioQueIncluiu, DataInclusao, DataUltimaAtualizacao) VALUES (?,?,?,?,?,?,?)";
    
   
    public TipoExperimentoControl(){
    }
    
        public void cadastrarTipoExperimento(TipoExperimentoBean tipoexperimento){
        
        try{
            ConexaoPost conexao = new ConexaoPost();
            pstm = (PreparedStatement) conexao.conectar().prepareStatement(cadastratipoexperimento);
            
            pstm.setString(1, tipoexperimento.getEmpresa());
            pstm.setString(1, tipoexperimento.getTipoexperimento());
            pstm.setString(1, tipoexperimento.getDesctipoexperimento());
            pstm.setString(1, tipoexperimento.getObservacao());
            pstm.setString(1, tipoexperimento.getUsuarioqueincluiu());
            pstm.setString(1, tipoexperimento.getDatainclusao());
            pstm.setString(1, tipoexperimento.getDataultimaatualizacao());
            
            pstm.executeUpdate();
            
            conexao.desconectar();
            
        }
        
        
        catch (Exception e){
            e.printStackTrace();
        }
    }
        
    public List<TipoExperimentoBean> TipoExperimentos(String tipoexperimento){
        List<TipoExperimentoBean> tipoexperimentos = null;
    
        try{
            ConexaoPost conecxao = new ConexaoPost();
            pstm = (PreparedStatement) conecxao.conectar().prepareStatement(consultatipoexperimento);
            pstm.setString(1, tipoexperimento);
            rs = pstm.executeQuery();
            TipoExperimentoBean tipexp;
            while (rs.next()){
                tipexp = new TipoExperimentoBean();
               
                tipexp.setEmpresa(rs.getString("empresa"));
                tipexp.setEmpresa(rs.getString("empresa"));
                tipexp.setTipoexperimento(rs.getString("tipoexperimento"));
                tipexp.setDesctipoexperimento(rs.getString("desctipoexperimento"));
                tipexp.setObservacao(rs.getString("observacao"));
                tipexp.setUsuarioqueincluiu(rs.getString("usuarioqueincluiu"));
                tipexp.setDatainclusao(rs.getString("datainclusao"));
                tipexp.setDataultimaatualizacao(rs.getString("dataultimaatualizacao"));


                tipoexperimentos.add(tipexp);
               
            }
            
            conecxao.desconectar();
        }
        catch(Exception e){
            e.printStackTrace();
        }
        return tipoexperimentos;
        
    }
    
}
